<?php

declare(strict_types=1);

namespace app\demo\controller\user;

use app\demo\controller\BaseUser;
use app\demo\model\ChooseSetType;
use think\facade\Session;
use think\facade\View;
use think\Request;
class Set extends BaseUser
{
    protected $model = null;

    public function __construct(Request $request){

        parent::__construct($request);
        $this->model = new \app\demo\model\ChooseSetType;
    }




    public function index()
    {

        return view();
    }




    public function form()
    {
        return view();
    }


    public function setinfo()
    {
        return view();
    }


    public function setlist()
    {
        return view();
    }
    public function settype()
    {
        $list = $this->model->select()->toArray();
        View::assign('list',$list);
        return view();
    }





    public function setform()
    {
        $name = $this->request->post('name');
        $price = $this->request->post('price');
        $logo = $this->request->post('logo');
        $id = $this->request->post('id');
        $uid = Session::get('uid');
        $data = [
            'id' => $id,
            'uid' => $uid,
            'name' => $name,
            'price' => $price,
            'logo' => $logo,
        ];
        $ChooseSetType = new ChooseSetType();
        $ChooseSetType->save($data);
        return success('操作成功');
    }

    public function getsetlist()
    {
        $list = $this->model->field('id,name,logo')->select();
       
        return success('操作成功',$list);
    }

}
